﻿using System;
using Teigha.Core;

namespace OdaOperation.Utils
{
    public class OdaWriteExtend
    {
        // 计算两个点之间的向量
        public static OdGeVector3d AngleTetweenVectors(OdGePoint3d p1, OdGePoint3d p2)
        {
            return p1.Sub(p2);
        }

        // 计算两个向量之间的夹角
        public static double AngleTetweenangleTo(OdGeVector3d v1, OdGeVector3d v2)
        {
            return v1.angleTo(v2);
        }

        // 将弧度转换为角度
        public static double RadianToAngle(double radian)
        {
            return 180.0 / Math.PI * radian;
        }

        // 将角度转换为弧度
        public static double AngleToRadian(double angle)
        {
            return Math.PI / 180.0 * angle;
        }

        // 计算圆弧的圆心坐标
        public static OdGePoint3d StrivesCenterCircle(OdGePoint3d p1, OdGePoint3d p2, double bulge)
        {
            double num = 0.5 * (1.0 / bulge - bulge);
            double xx = 0.5 * (p1.x + p2.x - num * (p2.y - p1.y));
            double yy = 0.5 * (p1.y + p2.y + num * (p2.x - p1.x));
            return new OdGePoint3d(xx, yy, 0.0);
        }
    }

}